class TrialPeriodsController < ApplicationController
  # GET /trial_periods
  # GET /trial_periods.xml
  def index
    @trial_periods = TrialPeriod.all

    respond_to do |format|
      format.html # index.html.erb
      format.xml  { render :xml => @trial_periods }
    end
  end

  # GET /trial_periods/1
  # GET /trial_periods/1.xml
  def show
    @trial_period = TrialPeriod.find(params[:id])

    respond_to do |format|
      format.html # show.html.erb
      format.xml  { render :xml => @trial_period }
    end
  end

  # GET /trial_periods/new
  # GET /trial_periods/new.xml
  def new
    @trial_period = TrialPeriod.new
    @bundle_variations = BundleVariation.find(:all)

    respond_to do |format|
      format.html # new.html.erb
      format.xml  { render :xml => @trial_period }
    end
  end

  # GET /trial_periods/1/edit
  def edit
    @trial_period = TrialPeriod.find(params[:id])
  end

  # POST /trial_periods
  # POST /trial_periods.xml
  def create
    @trial_period = TrialPeriod.new(params[:trial_period])
    @bundle_variations = BundleVariation.find(:all)
    

    respond_to do |format|
      if @trial_period.save
        flash[:notice] = 'TrialPeriod was successfully created.'
        format.html { redirect_to(@trial_period) }
        format.xml  { render :xml => @trial_period, :status => :created, :location => @trial_period }
      else
        format.html { render :action => "new" }
        format.xml  { render :xml => @trial_period.errors, :status => :unprocessable_entity }
      end
    end
  end

  # PUT /trial_periods/1
  # PUT /trial_periods/1.xml
  def update
    @trial_period = TrialPeriod.find(params[:id])

    respond_to do |format|
      if @trial_period.update_attributes(params[:trial_period])
        flash[:notice] = 'TrialPeriod was successfully updated.'
        format.html { redirect_to(@trial_period) }
        format.xml  { head :ok }
      else
        format.html { render :action => "edit" }
        format.xml  { render :xml => @trial_period.errors, :status => :unprocessable_entity }
      end
    end
  end

  # DELETE /trial_periods/1
  # DELETE /trial_periods/1.xml
  def destroy
    @trial_period = TrialPeriod.find(params[:id])
    @trial_period.destroy

    respond_to do |format|
      format.html { redirect_to(trial_periods_url) }
      format.xml  { head :ok }
    end
  end
end
